#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#define BUF_SIZE 200

typedef struct {
	int year;
	int month;
	int day;
	int hour;
	int minute;
	int second;
}Time_YMD_HMS;


char* getNowTime()
{
	Time_YMD_HMS *curDate =(Time_YMD_HMS *)malloc(sizeof(Time_YMD_HMS));
	char *timeBuf =(char *)malloc(BUF_SIZE);
	bzero(timeBuf,BUF_SIZE);
	bzero(curDate,sizeof(Time_YMD_HMS));
	time_t now;
	struct tm *timeNow;
	time(&now);
	timeNow = localtime(&now);
	curDate->year=timeNow->tm_year+1900;
	curDate->month=timeNow->tm_mon+1;
	curDate->day=timeNow->tm_mday;
	curDate->hour=timeNow->tm_hour;
	curDate->minute=timeNow->tm_min;
	curDate->second=timeNow->tm_sec;
	// yyyy-MM-dd HH:mm:ss
	if(curDate->second < 10)
		sprintf(timeBuf, "%d-%d-%d %d:%d:0%d",curDate->year,curDate->month,curDate->day,
								curDate->hour,curDate->minute,curDate->second);
	else
		sprintf(timeBuf, "%d-%d-%d %d:%d:%d",curDate->year,curDate->month,curDate->day,
								curDate->hour,curDate->minute,curDate->second);
	free(curDate);
	return timeBuf;
}
int main(int argc, char const *argv[])
{
	while(1)
	{
    	printf("%s\n",getNowTime());
    	usleep(1000*1000);
	}
    return 0;
}